package java67_adv8;

public class Thread5 extends Thread {
	public Thread5(String n) {
		super(n);
	}

	@Override
	public void run() {
		for (int i = 1; i <= 20; i++) {
			System.out.println(super.getName() + " print " + i);
			super.yield();
		}
	}

	public static void main(String[] args) {
		Thread5 t1 = new Thread5("线程1");
		Thread5 t2 = new Thread5("线程2");
		Thread5 t3 = new Thread5("线程3");
		t1.start();
		t2.start();
		t3.start();
		try {
			t1.join();
			t2.join();
			t3.join();
		} catch (InterruptedException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		// 保证主线程最后执行完,下面最后执行
		System.out.println("主线程的名字:" + Thread.currentThread().getName());

	}
}
